{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# This notebook serves as an example of how to create AutoTST objects and how to create 3D geometries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using Theano backend.\n"
     ]
    }
   ],
   "source": [
    "#General imports\n",
    "import os, sys\n",
    "import logging\n",
    "from copy import deepcopy\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from multiprocessing import Process\n",
    "\n",
    "#RDKit imports\n",
    "import rdkit\n",
    "from rdkit import Chem\n",
    "from rdkit.Chem import AllChem\n",
    "from rdkit.Chem.rdchem import Mol\n",
    "from rdkit.Chem.Pharm3D import EmbedLib\n",
    "from rdkit import DistanceGeometry\n",
    "from rdkit.Chem import rdDistGeom\n",
    "\n",
    "#ASE imports\n",
    "import ase\n",
    "from ase import Atom, Atoms\n",
    "from ase.calculators.gaussian import Gaussian as ASEGaussian\n",
    "from ase.visualize import view\n",
    "\n",
    "#RMG-Py imports\n",
    "from rmgpy.molecule import Molecule as RMGMolecule\n",
    "from rmgpy.species import Species as RMGSpecies\n",
    "from rmgpy.reaction import Reaction as RMGReaction\n",
    "\n",
    "#AutoTST imports\n",
    "from autotst.species import Species, Conformer\n",
    "from autotst.reaction import Reaction, TS \n",
    "from autotst.calculator.gaussian import Gaussian\n",
    "from autotst.calculator.statmech import StatMech\n",
    "from autotst.job.job import Job\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Creating `Species` and `Conformer` objects\n",
    "\n",
    "Each stable reactant and product species are generated as `Species` objects. These objects can contain many `Conformer` objects that can represent multiple resonance structures. \n",
    "`Species` and `Conformer` objects can be initialized as follows:\n",
    "- `Species([\"SMILES_STRING\"])`\n",
    "- `Conformer(\"SMILES_STRING\")`\n",
    "\n",
    "For a `Species` object, it can take lists of SMILES strings because there may be multiple resonance structures for a given SMILES structure. However, `Conformer` objects represent only a single isomer.\n",
    "`Species` objects can contain multiple `Conformer` and can be "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "smiles = [\"[CH2]C=C(C)C\"]\n",
    "for smile in smiles:\n",
    "    molecule = RMGMolecule(SMILES=smile)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For <Species \"[CH2]C=C(C)C / C=C[C](C)C\"> there are 2 resonance structures\n",
      "These structures are:\n",
      "\t- C=C[C](C)C\n",
      "\t- [CH2]C=C(C)C\n"
     ]
    }
   ],
   "source": [
    "species = Species([\"[CH2]C=C(C)C\"])\n",
    "print(\"For {} there are {} resonance structures\".format(species, len(species.conformers)))\n",
    "print(\"These structures are:\")\n",
    "for smiles in species.conformers.keys():\n",
    "    print (\"\\t- {}\".format(smiles))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'C=C[C](C)C': [<Conformer \"C=C[C](C)C\">],\n",
       " '[CH2]C=C(C)C': [<Conformer \"[CH2]C=C(C)C\">]}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "species.conformers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When looking at a specific `Conformer` object, you need to know that a `Species` contants a dictionary in `Species.conformers`. The keys are the possible SMILES strings associated with the species and the values are lists of `Conformer` objects for that specific SMILES. When initialized, these lists will be length 1 but will be extended if you generate more conformers. Below is how to view a single `Conformer` object "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683062879\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683062879\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683062879 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683062879\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683062879 = $3Dmol.createViewer($(\"#3dmolviewer_155683062879\"),{backgroundColor:\"white\"});\n\tviewer_155683062879.addModel(\"\\n     RDKit          3D\\n\\n 14 13  0  0  0  0  0  0  0  0999 V2000\\n   -0.0761    1.3774   -0.1265 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.6898   -0.5800    0.1007 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2794   -0.0916   -0.0505 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7072   -0.9566   -0.0205 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.1318   -0.6502    0.1794 C   0  0  0  0  0  3  0  0  0  0  0  0\\n   -1.0375    1.9099   -0.2000 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4257    1.7450    0.7974 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4801    1.6515   -1.0552 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.0629   -0.8213   -0.9092 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.3528    0.2353    0.4868 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7763   -1.4063    0.8203 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4819   -1.9596   -0.4007 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.6755   -0.3455   -0.7178 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.3725   -0.1080    1.0958 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  6  1  0\\n  1  7  1  0\\n  1  3  1  0\\n  1  8  1  0\\n  2 10  1  0\\n  2 11  1  0\\n  2  3  1  0\\n  2  9  1  0\\n  3  4  2  3\\n  4  5  1  0\\n  4 12  1  0\\n  5 14  1  0\\n  5 13  1  0\\nM  RAD  1   5   2\\nM  END\\n\",\"sdf\");\n\tviewer_155683062879.setStyle({\"stick\": {}});\n\tviewer_155683062879.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683062879.zoomTo();\nviewer_155683062879.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683062879\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683062879\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683062879 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683062879\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683062879 = $3Dmol.createViewer($(\"#3dmolviewer_155683062879\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683062879.addModel(\"\\n     RDKit          3D\\n\\n 14 13  0  0  0  0  0  0  0  0999 V2000\\n   -0.0761    1.3774   -0.1265 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.6898   -0.5800    0.1007 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2794   -0.0916   -0.0505 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7072   -0.9566   -0.0205 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.1318   -0.6502    0.1794 C   0  0  0  0  0  3  0  0  0  0  0  0\\n   -1.0375    1.9099   -0.2000 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4257    1.7450    0.7974 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4801    1.6515   -1.0552 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.0629   -0.8213   -0.9092 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.3528    0.2353    0.4868 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7763   -1.4063    0.8203 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4819   -1.9596   -0.4007 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.6755   -0.3455   -0.7178 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.3725   -0.1080    1.0958 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  6  1  0\\n  1  7  1  0\\n  1  3  1  0\\n  1  8  1  0\\n  2 10  1  0\\n  2 11  1  0\\n  2  3  1  0\\n  2  9  1  0\\n  3  4  2  3\\n  4  5  1  0\\n  4 12  1  0\\n  5 14  1  0\\n  5 13  1  0\\nM  RAD  1   5   2\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683062879.setStyle({\"stick\": {}});\n",
       "\tviewer_155683062879.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683062879.zoomTo();\n",
       "viewer_155683062879.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer = species.conformers[smiles][0]\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Creating `Reaction` and `TS` objects\n",
    "For this example we will be looking at a hydrogen abstraction reaction by peroxyl radical of 2-methylbut-2-ene"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, you need to initialize the autotst `Reaction` object as done below. This can be done by using either reaction strings that look like `r1+r2_p1+p2` where `r1`, `r2`, `p1`, and `p2` are smiles strings for the molecules involved in the reaction. In addition, not all reaction need to by bimolecular. AutoTST currently supports reactions of the following reaction families:\n",
    "- Hydrogen Abstraction (`H_Abstraction`: `r1+r2_p1+p2`)\n",
    "- Intra hydrogen migration (`intra_H_migration`: `r1_p1`)\n",
    "- R addition to multiple bond (`R_Addition_MultipleBond`: `r1+r2_p1`)\n",
    "\n",
    "You can specify a `reaction_family` in a `Reaction` object, however, it is not needed as AutoTST will attempt to match the reaction provided to one of the three supported reaction families.\n",
    "Alternatively, you can intialize a `Reaction` object using an `RMGReaction` object. This can be done as follows:\n",
    "\n",
    "`rxn = Reaction(rmg_reaction=RMGReaction())`\n",
    "\n",
    "The initialization of the reaction will also create a forward and a reverse transition state geometry. And these can be visualized using `py3dmol`.\n",
    "\n",
    "`Reaction` objects are similar to `Species` objects in that they both contain a dictionary corresponding to their conformers. The `Reaction.ts` is the dictionary of transition states for a reaction just like the `Species.conformers` is the dictionary of conformers for a species. The only difference is the keys for the `Reaction.ts` are simply `\"forward\"` and `\"reverse\"` to denote the `TS` generated in either direction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "reaction.py:231 load_databases INFO Loading RMG database from '/Users/nathan/Code/RMG-database/input'\n",
      "thermo.py:840 loadLibraries INFO Loading thermodynamics library from primaryThermoLibrary.py in /Users/nathan/Code/RMG-database/input/thermo/libraries...\n",
      "thermo.py:840 loadLibraries INFO Loading thermodynamics library from thermo_DFT_CCSDTF12_BAC.py in /Users/nathan/Code/RMG-database/input/thermo/libraries...\n",
      "thermo.py:840 loadLibraries INFO Loading thermodynamics library from CBS_QB3_1dHR.py in /Users/nathan/Code/RMG-database/input/thermo/libraries...\n",
      "thermo.py:857 loadGroups INFO Loading thermodynamics group database from /Users/nathan/Code/RMG-database/input/thermo/groups...\n",
      "transport.py:294 loadGroups INFO Loading transport group database from /Users/nathan/Code/RMG-database/input/transport/groups...\n",
      "statmech.py:529 loadGroups INFO Loading frequencies group database from /Users/nathan/Code/RMG-database/input/statmech/groups...\n",
      "base.py:220 load INFO Loading transitions state family groups from /Users/nathan/Code/AutoTST/database/R_Addition_MultipleBond/TS_groups.py\n",
      "base.py:220 load INFO Loading transitions state family groups from /Users/nathan/Code/AutoTST/database/H_Abstraction/TS_groups.py\n",
      "base.py:220 load INFO Loading transitions state family groups from /Users/nathan/Code/AutoTST/database/intra_H_migration/TS_groups.py\n",
      "reaction.py:394 get_labeled_reaction INFO Matched reaction to H_Abstraction family\n",
      "/Users/nathan/anaconda/envs/rmg_env/lib/python2.7/site-packages/py_rdl/Graph.py:112: UserWarning: trying to add edge that's already present!\n",
      "  warnings.warn(\"trying to add edge that's already present!\")\n",
      "species.py:118 __init__ INFO Could not generate resonance structures for this species... Using molecule provided\n",
      "species.py:118 __init__ INFO Could not generate resonance structures for this species... Using molecule provided\n"
     ]
    }
   ],
   "source": [
    "rxn = Reaction(label=\"CC=C(C)C+[O]O_[CH2]C=C(C)C+OO\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "reaction.py:309 generate_distance_data INFO The distance data is as follows: \n",
      "DistanceData(distances={'d12': 1.322228,'d13': 2.547443,'d23': 1.235329,}, uncertainties={'d12': 0.368943,'d13': 0.209844,'d23': 0.312795,}, comment='Matched node C/H3/Cd ([<Entry index=119 label=\"C/H3/Cd\">, <Entry index=210 label=\"Csj/Ct/H2\">])\\nMatched node OjO ([<Entry index=126 label=\"C/H2/Cd/Cd\">, <Entry index=32 label=\"OjO\">])\\n')\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:724 get_rdkit_mol INFO Getting bounds matrix\n",
      "reaction.py:759 get_bounds_matrix INFO before\n",
      "reaction.py:762 get_bounds_matrix INFO Got bounds matrix\n",
      "reaction.py:729 get_rdkit_mol INFO Editing bounds matrix\n",
      "reaction.py:779 set_limits INFO For atoms 4 and 7 we have a distance of: \t 1.322228\n",
      "reaction.py:779 set_limits INFO For atoms 7 and 1 we have a distance of: \t 1.235329\n",
      "reaction.py:779 set_limits INFO For atoms 4 and 1 we have a distance of: \t 2.547443\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.537443 to 2.477557\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 3.65 to 3.31857083943\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.9 to 2.471329\n",
      "reaction.py:732 get_rdkit_mol INFO Performing triangle smoothing on bounds matrix.\n",
      "reaction.py:735 get_rdkit_mol INFO Now attempting to embed using edited bounds matrix.\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:724 get_rdkit_mol INFO Getting bounds matrix\n",
      "reaction.py:759 get_bounds_matrix INFO before\n",
      "reaction.py:762 get_bounds_matrix INFO Got bounds matrix\n",
      "reaction.py:729 get_rdkit_mol INFO Editing bounds matrix\n",
      "reaction.py:779 set_limits INFO For atoms 1 and 17 we have a distance of: \t 1.322228\n",
      "reaction.py:779 set_limits INFO For atoms 17 and 6 we have a distance of: \t 1.235329\n",
      "reaction.py:779 set_limits INFO For atoms 1 and 6 we have a distance of: \t 2.547443\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 3.65 to 3.07807213735\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.537443 to 2.477557\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 3.15 to 2.644329\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.4 to 2.26472979488\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.4 to 2.26472979488\n",
      "reaction.py:732 get_rdkit_mol INFO Performing triangle smoothing on bounds matrix.\n",
      "reaction.py:735 get_rdkit_mol INFO Now attempting to embed using edited bounds matrix.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'forward': [<TS \"CC=C(C)C.[O]O\">], 'reverse': [<TS \"OO.[CH2]C=C(C)C\">]}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "transitionstates = rxn.ts[\"reverse\"] #the rxn.ts is a dictionary with keys being \"forward\" and \"reverse\"\n",
    "ts = transitionstates[0] #transitionstates is a list of TS objects, this list is currently length 1\n",
    "rxn.ts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Editing geometries of `Conformer` and `TS` objects\n",
    "\n",
    "AutoTST allows you to edit the following features of a `Conformer` or a `TS` object:\n",
    "- Bond length\n",
    "- Angles\n",
    "- Dihedrals\n",
    "- CisTrans bond orientation\n",
    "- Sterocenter orientation\n",
    "\n",
    "The definitions for all of these objects can be found in `geometry.py`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063905\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063905\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063905 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063905\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063905 = $3Dmol.createViewer($(\"#3dmolviewer_155683063905\"),{backgroundColor:\"white\"});\n\tviewer_155683063905.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n    0.4446    1.8565    0.6550 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.4920    1.0294   -0.2920 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2637   -0.8589    1.5517 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.4583   -0.5739    0.1960 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7337   -0.5586   -0.1943 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.0399    0.7616   -1.3902 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.1282   -1.3295   -0.8597 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.0490   -0.0982    2.1984 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063905.setStyle({\"stick\": {}});\n\tviewer_155683063905.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063905.zoomTo();\nviewer_155683063905.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063905\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063905\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063905 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063905\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063905 = $3Dmol.createViewer($(\"#3dmolviewer_155683063905\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063905.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n    0.4446    1.8565    0.6550 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.4920    1.0294   -0.2920 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2637   -0.8589    1.5517 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.4583   -0.5739    0.1960 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7337   -0.5586   -0.1943 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.0399    0.7616   -1.3902 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.1282   -1.3295   -0.8597 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.0490   -0.0982    2.1984 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063905.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063905.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063905.zoomTo();\n",
       "viewer_155683063905.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Conformer \"ClC=C(O)C(N)Cl\"> has the following geometries:\n",
      "\n",
      "Bonds\n",
      "\t- <Bond \"(0, 4)\">: 0\n",
      "\t- <Bond \"(1, 6)\">: 1\n",
      "\t- <Bond \"(2, 5)\">: 2\n",
      "\t- <Bond \"(2, 11)\">: 3\n",
      "\t- <Bond \"(3, 8)\">: 4\n",
      "\t- <Bond \"(3, 9)\">: 5\n",
      "\t- <Bond \"(3, 4)\">: 6\n",
      "\t- <Bond \"(4, 5)\">: 7\n",
      "\t- <Bond \"(4, 7)\">: 8\n",
      "\t- <Bond \"(5, 6)\">: 9\n",
      "\t- <Bond \"(6, 10)\">: 10\n",
      "\n",
      "Angles\n",
      "\t- <Angle \"(0, 4, 3)\">: 0\n",
      "\t- <Angle \"(0, 4, 5)\">: 1\n",
      "\t- <Angle \"(0, 4, 7)\">: 2\n",
      "\t- <Angle \"(1, 6, 5)\">: 3\n",
      "\t- <Angle \"(1, 6, 10)\">: 4\n",
      "\t- <Angle \"(2, 5, 4)\">: 5\n",
      "\t- <Angle \"(2, 5, 6)\">: 6\n",
      "\t- <Angle \"(3, 4, 5)\">: 7\n",
      "\t- <Angle \"(3, 4, 7)\">: 8\n",
      "\t- <Angle \"(4, 3, 8)\">: 9\n",
      "\t- <Angle \"(4, 3, 9)\">: 10\n",
      "\t- <Angle \"(4, 5, 6)\">: 11\n",
      "\t- <Angle \"(5, 2, 11)\">: 12\n",
      "\t- <Angle \"(5, 4, 7)\">: 13\n",
      "\t- <Angle \"(5, 6, 10)\">: 14\n",
      "\t- <Angle \"(8, 3, 9)\">: 15\n",
      "\n",
      "Dihedrals\n",
      "\t- <Torsion \"(11, 2, 5, 6)\">: 0\n",
      "\t- <Torsion \"(9, 3, 4, 7)\">: 1\n",
      "\t- <Torsion \"(7, 4, 5, 6)\">: 2\n",
      "\n",
      "CisTrans Bonds\n",
      "\t- <CisTrans \"[4, 5, 6, 10] - Z\">: \n",
      "\n",
      "Chiral Centers\n",
      "\t- <ChiralCenter \"4 - ?\">: 0\n"
     ]
    }
   ],
   "source": [
    "conformer = Conformer(\"ClC=C(O)C(N)Cl\")\n",
    "conformer.view()\n",
    "print(\"{} has the following geometries:\".format(conformer))\n",
    "print(\"\")\n",
    "print(\"Bonds\")\n",
    "for bond in conformer.bonds:\n",
    "    print(\"\\t- {}: {}\".format(bond, bond.index))\n",
    "    \n",
    "print(\"\")\n",
    "print(\"Angles\")\n",
    "for angle in conformer.angles:\n",
    "    print(\"\\t- {}: {}\".format(angle, angle.index))\n",
    "    \n",
    "print(\"\")\n",
    "print(\"Dihedrals\")\n",
    "for torsion in conformer.torsions:\n",
    "    print(\"\\t- {}: {}\".format(torsion, torsion.index))\n",
    "    \n",
    "print(\"\")\n",
    "print(\"CisTrans Bonds\")\n",
    "for cistran in conformer.cistrans:\n",
    "    print(\"\\t- {}: \".format(cistran, cistran.index))\n",
    "    \n",
    "print(\"\")\n",
    "print(\"Chiral Centers\")\n",
    "for chiral_center in conformer.chiral_centers:\n",
    "    print(\"\\t- {}: {}\".format(chiral_center, chiral_center.index))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition, you can set variables for each of these objects. This next section of the notebook will walk though how to do all of this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063908\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063908\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063908 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063908\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063908 = $3Dmol.createViewer($(\"#3dmolviewer_155683063908\"),{backgroundColor:\"white\"});\n\tviewer_155683063908.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n    0.4446    1.8565    0.6550 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.4920    1.0294   -0.2920 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2637   -0.8589    1.5517 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.4583   -0.5739    0.1960 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7337   -0.5586   -0.1943 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.0399    0.7616   -1.3902 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.1282   -1.3295   -0.8597 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.3670    1.3757    3.4514 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063908.setStyle({\"stick\": {}});\n\tviewer_155683063908.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063908.zoomTo();\nviewer_155683063908.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063908\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063908\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063908 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063908\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063908 = $3Dmol.createViewer($(\"#3dmolviewer_155683063908\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063908.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n    0.4446    1.8565    0.6550 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.4920    1.0294   -0.2920 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.2637   -0.8589    1.5517 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.4583   -0.5739    0.1960 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.7337   -0.5586   -0.1943 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.0399    0.7616   -1.3902 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n   -2.1282   -1.3295   -0.8597 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.3670    1.3757    3.4514 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063908.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063908.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063908.zoomTo();\n",
       "viewer_155683063908.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer.set_bond_length(bond_index=3, length=3) #Length is specified in angstroms\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063912\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063912\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063912 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063912\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063912 = $3Dmol.createViewer($(\"#3dmolviewer_155683063912\"),{backgroundColor:\"white\"});\n\tviewer_155683063912.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.2137    0.9392    1.1520 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.2248   -1.9585    0.2657 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4036   -1.9733   -0.4085 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3986    0.3040   -1.1080 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.5599   -2.5946   -1.2929 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063912.setStyle({\"stick\": {}});\n\tviewer_155683063912.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063912.zoomTo();\nviewer_155683063912.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063912\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063912\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063912 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063912\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063912 = $3Dmol.createViewer($(\"#3dmolviewer_155683063912\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063912.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.2137    0.9392    1.1520 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.2248   -1.9585    0.2657 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.7716   -0.0724   -0.6575 N   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4544    0.4420   -0.4116 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.4036   -1.9733   -0.4085 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3986    0.3040   -1.1080 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.5415    0.4959   -0.2650 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8730   -1.0940   -0.5308 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.5599   -2.5946   -1.2929 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063912.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063912.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063912.zoomTo();\n",
       "viewer_155683063912.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer.set_angle(angle_index=7, angle=45.) #Angles are specified in degrees\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063914\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063914\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063914 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063914\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063914 = $3Dmol.createViewer($(\"#3dmolviewer_155683063914\"),{backgroundColor:\"white\"});\n\tviewer_155683063914.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.5587   -2.3350    1.1916 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8630   -3.1172   -1.5601 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5282   -1.5045   -1.3093 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.9025   -1.1202   -0.7962 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8063   -0.9465   -2.2059 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063914.setStyle({\"stick\": {}});\n\tviewer_155683063914.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063914.zoomTo();\nviewer_155683063914.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063914\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063914\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063914 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063914\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063914 = $3Dmol.createViewer($(\"#3dmolviewer_155683063914\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063914.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.5587   -2.3350    1.1916 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8630   -3.1172   -1.5601 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5282   -1.5045   -1.3093 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.9025   -1.1202   -0.7962 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8063   -0.9465   -2.2059 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063914.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063914.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063914.zoomTo();\n",
       "viewer_155683063914.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer.set_torsion(torsion_index=0, dihedral=180)\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063916\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063916\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063916 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063916\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063916 = $3Dmol.createViewer($(\"#3dmolviewer_155683063916\"),{backgroundColor:\"white\"});\n\tviewer_155683063916.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.5587   -2.3350    1.1916 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8630   -3.1172   -1.5601 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5282   -1.5045   -1.3093 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.9025   -1.1202   -0.7962 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8063   -0.9465   -2.2059 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063916.setStyle({\"stick\": {}});\n\tviewer_155683063916.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063916.zoomTo();\nviewer_155683063916.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063916\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063916\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063916 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063916\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063916 = $3Dmol.createViewer($(\"#3dmolviewer_155683063916\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063916.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.5587   -2.3350    1.1916 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8630   -3.1172   -1.5601 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.0246   -0.9555    0.8706 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.1310   -0.8744   -0.2027 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5282   -1.5045   -1.3093 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.9025   -1.1202   -0.7962 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.8063   -0.9465   -2.2059 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.3389    0.3884    3.4636 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  0\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063916.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063916.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063916.zoomTo();\n",
       "viewer_155683063916.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer.set_cistrans(cistrans_index=0, stero=\"z\") #options for stero are E and Z\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/3dmoljs_load.v0": "<div id=\"3dmolviewer_155683063926\"  style=\"position: relative; width: 600px; height: 600px\">\n        <p id=\"3dmolwarning_155683063926\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n        </div>\n<script>\n\nvar loadScriptAsync = function(uri){\n  return new Promise((resolve, reject) => {\n    var tag = document.createElement('script');\n    tag.src = uri;\n    tag.async = true;\n    tag.onload = () => {\n      resolve();\n    };\n  var firstScriptTag = document.getElementsByTagName('script')[0];\n  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n});\n};\n\nif(typeof $3Dmolpromise === 'undefined') {\n$3Dmolpromise = null;\n  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n}\n\nvar viewer_155683063926 = null;\nvar warn = document.getElementById(\"3dmolwarning_155683063926\");\nif(warn) {\n    warn.parentNode.removeChild(warn);\n}\n$3Dmolpromise.then(function() {\nviewer_155683063926 = $3Dmol.createViewer($(\"#3dmolviewer_155683063926\"),{backgroundColor:\"white\"});\n\tviewer_155683063926.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.1612   -2.6650    0.4734 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.0749   -2.0302   -2.6561 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.1122   -0.9250   -0.2217 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8547   -0.5354   -0.6950 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7154   -0.5888   -2.0205 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.2490   -0.7998   -0.4662 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.6175    0.3230   -2.6135 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.6537   -0.8845    2.7287 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  6\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n\tviewer_155683063926.setStyle({\"stick\": {}});\n\tviewer_155683063926.setBackgroundColor(\"0xeeeeee\");\n\tviewer_155683063926.zoomTo();\nviewer_155683063926.render();\n});\n</script>",
      "text/html": [
       "<div id=\"3dmolviewer_155683063926\"  style=\"position: relative; width: 600px; height: 600px\">\n",
       "        <p id=\"3dmolwarning_155683063926\" style=\"background-color:#ffcccc;color:black\">You appear to be running in JupyterLab.  You need to install the 3dmol extension: <br>\n",
       "        <tt>jupyter labextension install jupyterlab_3dmol</tt></p>\n",
       "        </div>\n",
       "<script>\n",
       "\n",
       "var loadScriptAsync = function(uri){\n",
       "  return new Promise((resolve, reject) => {\n",
       "    var tag = document.createElement('script');\n",
       "    tag.src = uri;\n",
       "    tag.async = true;\n",
       "    tag.onload = () => {\n",
       "      resolve();\n",
       "    };\n",
       "  var firstScriptTag = document.getElementsByTagName('script')[0];\n",
       "  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n",
       "});\n",
       "};\n",
       "\n",
       "if(typeof $3Dmolpromise === 'undefined') {\n",
       "$3Dmolpromise = null;\n",
       "  $3Dmolpromise = loadScriptAsync('https://3dmol.csb.pitt.edu/build/3Dmol.js');\n",
       "}\n",
       "\n",
       "var viewer_155683063926 = null;\n",
       "var warn = document.getElementById(\"3dmolwarning_155683063926\");\n",
       "if(warn) {\n",
       "    warn.parentNode.removeChild(warn);\n",
       "}\n",
       "$3Dmolpromise.then(function() {\n",
       "viewer_155683063926 = $3Dmol.createViewer($(\"#3dmolviewer_155683063926\"),{backgroundColor:\"white\"});\n",
       "\tviewer_155683063926.addModel(\"\\n     RDKit          3D\\n\\n 12 11  0  0  0  0  0  0  0  0999 V2000\\n   -0.1612   -2.6650    0.4734 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.0749   -2.0302   -2.6561 Cl  0  0  0  0  0  0  0  0  0  0  0  0\\n    2.1122   -0.9250   -0.2217 O   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7024    0.0627    0.2428 N   0  0  0  0  0  0  0  0  0  0  0  0\\n   -0.3244   -0.9342    0.1326 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8547   -0.5354   -0.6950 C   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.7154   -0.5888   -2.0205 C   0  0  0  0  0  0  0  0  0  0  0  0\\n   -1.2490   -0.7998   -0.4662 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.8018    0.4836    1.1824 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    1.5929   -0.1726   -0.2279 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    0.6175    0.3230   -2.6135 H   0  0  0  0  0  0  0  0  0  0  0  0\\n    2.6537   -0.8845    2.7287 H   0  0  0  0  0  0  0  0  0  0  0  0\\n  1  5  1  6\\n  2  7  1  0\\n  3  6  1  0\\n  3 12  1  0\\n  4  9  1  0\\n  4 10  1  0\\n  4  5  1  0\\n  5  6  1  0\\n  5  8  1  0\\n  6  7  2  3\\n  7 11  1  0\\nM  END\\n\",\"sdf\");\n",
       "\tviewer_155683063926.setStyle({\"stick\": {}});\n",
       "\tviewer_155683063926.setBackgroundColor(\"0xeeeeee\");\n",
       "\tviewer_155683063926.zoomTo();\n",
       "viewer_155683063926.render();\n",
       "});\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conformer.set_chirality(chiral_center_index=0, stero=\"r\")\n",
    "conformer.set_chirality??\n",
    "conformer.view()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## AND all of these features can be extended to `TS` objects as well "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Now, let's look at how to generate ensembles of conformers for `Species` and `Reactions` using AutoTST\n",
    "\n",
    "Both `Species` and `Reaction` objects have a built-in method called `generate_conformers` and this method takes one argument of an ASE calculator object. This method will then generate all possible combinations of dihedrals, CisTrans bonds, and chiral centers to identify every possible conformer. All of these conformers are then optimized using ASE's BFGS optimizer and the calculator that a user provides. From this, a list of conformers within 1 kcal/mol are generated and added to the `Species.conformers` or the `Reaction.ts` dict. Below are a few examples."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      " _           _    _     _ _\n",
      "| |__   ___ | |_ | |__ |_| |_\n",
      "|  _ \\ / _ \\|  _||  _ \\| |  _|\n",
      "| | | | ( ) | |_ | ( ) | | |_\n",
      "|_| |_|\\___/ \\__|\\____/|_|\\__|  ver. 0.1 (svn=Unversioned directory)\n",
      "Distributed under GNU GPL; see /Users/nathan/Code/hb/lib/python/LICENSE\n",
      "Date: Thu May  2 16:57:19 2019\n",
      "Nodename: Nathans-MacBook.local\n",
      "Arch: x86_64\n",
      "Dir: /Users/nathan/Code/AutoTST/ipython_notebooks\n",
      "System: H10C4\n",
      "       Charge= 0.0\n",
      "       Container Bravais: pbc:[0,0,0], cell:[0.00,0.00,0.00] Ang, \n",
      "   cosines(12,13,23):[nan,nan,nan]\n",
      "Symmetry operations (if any):\n",
      "       0: pbc= False , kappa-points=1, M=1\n",
      "       1: pbc= False , kappa-points=1, M=1\n",
      "       2: pbc= False , kappa-points=1, M=1\n",
      "Electronic temperature: 0.02 eV\n",
      "Mixer: Anderson with memory = 3 , mixing parameter = 0.2\n",
      "14 atoms, 26 states, 26.0 electrons (13.0 filled states)\n",
      "Initial n ranges:[0,0] [0,0] [0,0] \n",
      "Element C in /Users/nathan/Code/hb/param/C.elm\n",
      "    *no comment\n",
      "Element H in /Users/nathan/Code/hb/param/H.elm\n",
      "    *Standard H-atom\n",
      "\n",
      "Interactions:\n",
      "  CC in /Users/nathan/Code/hb/param/C_C.par\n",
      "    *(r/r0)**2, r0=1.85*r_cov, standard CC\n",
      "  CH in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no slako doc\n",
      "  HC in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no slako doc\n",
      "  HH in /Users/nathan/Code/hb/param/H_H.par\n",
      "    *no slako doc\n",
      "\n",
      "Repulsions:\n",
      "  CC in /Users/nathan/Code/hb/param/C_C.par\n",
      "    *no repulsion doc\n",
      "  CH in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no repulsion doc\n",
      "  HH in /Users/nathan/Code/hb/param/H_H.par\n",
      "    *no repulsion doc\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "systematic.py:192 systematic_search INFO There are 6 unique conformers generated\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~92.899 % filled.\n",
      "Hamiltonian ~92.899 % filled.\n",
      "Hamiltonian ~92.899 % filled.\n",
      "Hamiltonian ~92.899 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~92.899 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~92.899 % filled.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "systematic.py:287 systematic_search INFO We have identified 5 unique conformers for <Conformer \"CCCC\">\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Solved zero times.\n",
      "\n",
      "Timing:\n",
      "            label                    time     calls    %sub  %covered   %tot\n",
      "-------------------------------------------------------------------------------\n",
      "Hotbit                              21.267         1 (100.0 %,  1.4 %) 100.0 % |000000000000000000000000000000|\n",
      "../initialization                    0.303         1 (  1.4 %        )   1.4 % ||\n",
      " -------------------------------------------------------------------------------\n",
      "total time       21.267 seconds      0 h  0 min  21 sec\n",
      "Thu May  2 16:57:40 2019\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'CCCC': [<Conformer \"CCCC\">,\n",
       "  <Conformer \"CCCC\">,\n",
       "  <Conformer \"CCCC\">,\n",
       "  <Conformer \"CCCC\">,\n",
       "  <Conformer \"CCCC\">]}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from hotbit import Hotbit\n",
    "species = Species([\"CCCC\"])\n",
    "species.generate_conformers(calculator=Hotbit())\n",
    "species.conformers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "reaction.py:394 get_labeled_reaction INFO Matched reaction to H_Abstraction family\n",
      "species.py:118 __init__ INFO Could not generate resonance structures for this species... Using molecule provided\n",
      "species.py:118 __init__ INFO Could not generate resonance structures for this species... Using molecule provided\n",
      "reaction.py:304 generate_distance_data INFO Distance between *1 and *3 is too small, setting it to lower bound of uncertainty\n",
      "reaction.py:309 generate_distance_data INFO The distance data is as follows: \n",
      "DistanceData(distances={'d12': 1.415393,'d13': 2.434963,'d23': 1.127452,}, uncertainties={'d12': 0.368199,'d13': 0.209098,'d23': 0.288777,}, comment='Matched node C_methane ([<Entry index=43 label=\"C_methane\">, <Entry index=103 label=\"CsjCH2\">])\\nMatched node OjO ([<Entry index=126 label=\"C/H2/Cd/Cd\">, <Entry index=32 label=\"OjO\">])\\n')\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:724 get_rdkit_mol INFO Getting bounds matrix\n",
      "reaction.py:759 get_bounds_matrix INFO before\n",
      "reaction.py:762 get_bounds_matrix INFO Got bounds matrix\n",
      "reaction.py:729 get_rdkit_mol INFO Editing bounds matrix\n",
      "reaction.py:779 set_limits INFO For atoms 2 and 3 we have a distance of: \t 1.415393\n",
      "reaction.py:779 set_limits INFO For atoms 3 and 1 we have a distance of: \t 1.127452\n",
      "reaction.py:779 set_limits INFO For atoms 2 and 1 we have a distance of: \t 2.434963\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.9 to 2.363452\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.9 to 2.88941758085\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.9 to 2.88941758085\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.9 to 2.88941758085\n",
      "reaction.py:732 get_rdkit_mol INFO Performing triangle smoothing on bounds matrix.\n",
      "reaction.py:735 get_rdkit_mol INFO Now attempting to embed using edited bounds matrix.\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:719 get_rdkit_mol INFO Initially embedded molecule\n",
      "reaction.py:724 get_rdkit_mol INFO Getting bounds matrix\n",
      "reaction.py:759 get_bounds_matrix INFO before\n",
      "reaction.py:762 get_bounds_matrix INFO Got bounds matrix\n",
      "reaction.py:729 get_rdkit_mol INFO Editing bounds matrix\n",
      "reaction.py:779 set_limits INFO For atoms 1 and 7 we have a distance of: \t 1.415393\n",
      "reaction.py:779 set_limits INFO For atoms 7 and 2 we have a distance of: \t 1.127452\n",
      "reaction.py:779 set_limits INFO For atoms 1 and 2 we have a distance of: \t 2.434963\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 3.65 to 2.97019513735\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.4 to 2.15685279488\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.4 to 2.15685279488\n",
      "reaction.py:814 bm_pre_edit INFO Changing lower limit 2.4 to 2.15685279488\n",
      "reaction.py:732 get_rdkit_mol INFO Performing triangle smoothing on bounds matrix.\n",
      "reaction.py:735 get_rdkit_mol INFO Now attempting to embed using edited bounds matrix.\n",
      "systematic.py:192 systematic_search INFO There are 17 unique conformers generated\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      " _           _    _     _ _\n",
      "| |__   ___ | |_ | |__ |_| |_\n",
      "|  _ \\ / _ \\|  _||  _ \\| |  _|\n",
      "| | | | ( ) | |_ | ( ) | | |_\n",
      "|_| |_|\\___/ \\__|\\____/|_|\\__|  ver. 0.1 (svn=Unversioned directory)\n",
      "Distributed under GNU GPL; see /Users/nathan/Code/hb/lib/python/LICENSE\n",
      "Date: Thu May  2 16:57:41 2019\n",
      "Nodename: Nathans-MacBook.local\n",
      "Arch: x86_64\n",
      "Dir: /Users/nathan/Code/AutoTST/ipython_notebooks\n",
      "System: H5CO2\n",
      "       Charge= 0.0\n",
      "       Container Bravais: pbc:[0,0,0], cell:[0.00,0.00,0.00] Ang, \n",
      "   cosines(12,13,23):[nan,nan,nan]\n",
      "Symmetry operations (if any):\n",
      "       0: pbc= False , kappa-points=1, M=1\n",
      "       1: pbc= False , kappa-points=1, M=1\n",
      "       2: pbc= False , kappa-points=1, M=1\n",
      "Electronic temperature: 0.02 eV\n",
      "Mixer: Anderson with memory = 3 , mixing parameter = 0.2\n",
      "8 atoms, 17 states, 21.0 electrons (10.5 filled states)\n",
      "Initial n ranges:[0,0] [0,0] [0,0] \n",
      "Element O in /Users/nathan/Code/hb/param/O.elm\n",
      "    *no comment\n",
      "Element C in /Users/nathan/Code/hb/param/C.elm\n",
      "    *no comment\n",
      "Element H in /Users/nathan/Code/hb/param/H.elm\n",
      "    *Standard H-atom\n",
      "\n",
      "Interactions:\n",
      "  OO in /Users/nathan/Code/hb/param/O_O.par\n",
      "    *test parameters 23.6 2008\n",
      "  OC in /Users/nathan/Code/hb/param/C_O.par\n",
      "    *test parameters 23.6 2008\n",
      "  OH in /Users/nathan/Code/hb/param/O_H.par\n",
      "    *test parameters 23.6 2008\n",
      "  CO in /Users/nathan/Code/hb/param/C_O.par\n",
      "    *test parameters 23.6 2008\n",
      "  CC in /Users/nathan/Code/hb/param/C_C.par\n",
      "    *(r/r0)**2, r0=1.85*r_cov, standard CC\n",
      "  CH in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no slako doc\n",
      "  HO in /Users/nathan/Code/hb/param/O_H.par\n",
      "    *test parameters 23.6 2008\n",
      "  HC in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no slako doc\n",
      "  HH in /Users/nathan/Code/hb/param/H_H.par\n",
      "    *no slako doc\n",
      "\n",
      "Repulsions:\n",
      "  OO in /Users/nathan/Code/hb/param/O_O.par\n",
      "    *test parameters 23.6 2008\n",
      "  OC in /Users/nathan/Code/hb/param/C_O.par\n",
      "    *test parameters 23.6 2008\n",
      "  OH in /Users/nathan/Code/hb/param/O_H.par\n",
      "    *test parameters 23.6 2008\n",
      "  CC in /Users/nathan/Code/hb/param/C_C.par\n",
      "    *no repulsion doc\n",
      "  CH in /Users/nathan/Code/hb/param/C_H.par\n",
      "    *no repulsion doc\n",
      "  HH in /Users/nathan/Code/hb/param/H_H.par\n",
      "    *no repulsion doc\n",
      "\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "systematic.py:287 systematic_search INFO We have identified 4 unique conformers for <TS \"C.[O]O\">\n",
      "systematic.py:192 systematic_search INFO There are 17 unique conformers generated\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Memory consumption estimate: > 0.00 GB\n",
      "Hamiltonian ~87.543 % filled.\n",
      "Hamiltonian ~87.543 % filled.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "systematic.py:287 systematic_search INFO We have identified 6 unique conformers for <TS \"OO.[CH3]\">\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Solved zero times.\n",
      "\n",
      "Timing:\n",
      "            label                    time     calls    %sub  %covered   %tot\n",
      "-------------------------------------------------------------------------------\n",
      "Hotbit                             100.406         1 (100.0 %,  0.3 %) 100.0 % |000000000000000000000000000000|\n",
      "../initialization                    0.327         1 (  0.3 %        )   0.3 % ||\n",
      " -------------------------------------------------------------------------------\n",
      "total time      100.406 seconds      0 h  1 min  40 sec\n",
      "Thu May  2 16:59:21 2019\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'forward': [<TS \"C.[O]O\">, <TS \"C.[O]O\">, <TS \"C.[O]O\">, <TS \"C.[O]O\">],\n",
       " 'reverse': [<TS \"OO.[CH3]\">,\n",
       "  <TS \"OO.[CH3]\">,\n",
       "  <TS \"OO.[CH3]\">,\n",
       "  <TS \"OO.[CH3]\">,\n",
       "  <TS \"OO.[CH3]\">,\n",
       "  <TS \"OO.[CH3]\">]}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reaction = Reaction(\"C+[O]O_[CH3]+OO\")\n",
    "reaction.generate_conformers(calculator=Hotbit())\n",
    "reaction.ts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For right now, we're going to be looking at the first conformers for the `Species` and `Reaction` listed above."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts = reaction.ts[\"forward\"][0]\n",
    "conformer = species.conformers[\"CCCC\"][0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Now, to look at writing input files for `Conformer` and `TS` objects\n",
    "\n",
    "This is realitively easy, you just need to use the `Gaussian` calculator object to do all of this. This starts with an initialzation of the object followed by calling it's methods on different objects to get ASE calculator objects that can write your geometries.\n",
    "\n",
    "The main methods of the `Gaussian` calculator are:\n",
    "- For species conformers \n",
    "    - `get_conformer_calc`\n",
    "- For transition states\n",
    "    - `get_shell_calc`\n",
    "    - `get_center_calc`\n",
    "    - `get_overall_calc`\n",
    "    - `get_irc_calc`\n",
    "- For both\n",
    "    - `get_rotor_calc`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "gaussian = Gaussian()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For `Conformer` objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CCCC_0\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ opt=(calcfc,verytight,gdiis,maxcycles=900) freq IOP(7/33=1,2/16=3) scf=(maxcycle=900) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 1\n",
      "C                 0.7354773892       -0.5134376003       -0.4435545991\n",
      "C                -0.6152275702       -0.7833727200        0.1347266939\n",
      "C                 1.4708785306        0.6001543075        0.2570064789\n",
      "C                -1.5576774464        0.3717083329       -0.0133286741\n",
      "H                 1.3514541492       -1.4408514250       -0.3998148131\n",
      "H                 0.6384864521       -0.2543841110       -1.5085983108\n",
      "H                -1.0592735869       -1.6822519107       -0.3636475485\n",
      "H                -0.5140400339       -1.0467673405        1.2016221745\n",
      "H                 0.9226907733        1.5490177860        0.1594326502\n",
      "H                 1.5916942864        0.3858269094        1.3352985542\n",
      "H                 2.4876999397        0.7411498210       -0.1864867196\n",
      "H                -1.9843555104        0.4010061669       -1.0420713857\n",
      "H                -1.0400176453        1.3206480008        0.1611748412\n",
      "H                -2.3995677519        0.3031307160        0.6992443636\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "calc = gaussian.get_conformer_calc(conformer=conformer)\n",
    "calc.write_input(conformer.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For `TS` objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C+[O]O_[CH3]+OO_forward_shell_0\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ Opt=(ModRedun,Loose,maxcycles=900) Int(Grid=SG1) scf=(maxcycle=900) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 2\n",
      "O                 3.1075007166        0.0366083817        1.1380898417\n",
      "O                 2.7719170395       -0.9838382949        0.3778717969\n",
      "C                 1.8945968834        0.2679645289       -1.5076958826\n",
      "H                 2.0535769134       -0.5567744322       -0.3833424702\n",
      "H                 2.1299086782       -0.3061419699       -2.4273764453\n",
      "H                 0.8496485340        0.6404518280       -1.5151018938\n",
      "H                 2.6179912682        1.0940032327       -1.3491742317\n",
      "H                 3.9834411235        0.3211441193        0.7742050968\n",
      "\n",
      "3 4 F\n",
      "4 2 F\n",
      "3 4 2 F\n",
      "\n"
     ]
    }
   ],
   "source": [
    "calc = gaussian.get_shell_calc(ts=ts)\n",
    "calc.write_input(ts.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C+[O]O_[CH3]+OO_forward_center_0\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ Opt=(ts,calcfc,noeigentest,ModRedun,maxcycles=900) scf=(maxcycle=900) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 2\n",
      "O                 3.1075007166        0.0366083817        1.1380898417\n",
      "O                 2.7719170395       -0.9838382949        0.3778717969\n",
      "C                 1.8945968834        0.2679645289       -1.5076958826\n",
      "H                 2.0535769134       -0.5567744322       -0.3833424702\n",
      "H                 2.1299086782       -0.3061419699       -2.4273764453\n",
      "H                 0.8496485340        0.6404518280       -1.5151018938\n",
      "H                 2.6179912682        1.0940032327       -1.3491742317\n",
      "H                 3.9834411235        0.3211441193        0.7742050968\n",
      "\n",
      "1 5 F\n",
      "1 6 F\n",
      "1 7 F\n",
      "1 8 F\n",
      "5 6 F\n",
      "5 7 F\n",
      "5 8 F\n",
      "6 7 F\n",
      "6 8 F\n",
      "7 8 F\n",
      "\n"
     ]
    }
   ],
   "source": [
    "calc = gaussian.get_center_calc(ts=ts)\n",
    "calc.write_input(ts.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C+[O]O_[CH3]+OO_forward_0\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ opt=(ts,calcfc,noeigentest,maxcycles=900) freq scf=(maxcycle=900) IOP(7/33=1,2/16=3) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 2\n",
      "O                 3.1075007166        0.0366083817        1.1380898417\n",
      "O                 2.7719170395       -0.9838382949        0.3778717969\n",
      "C                 1.8945968834        0.2679645289       -1.5076958826\n",
      "H                 2.0535769134       -0.5567744322       -0.3833424702\n",
      "H                 2.1299086782       -0.3061419699       -2.4273764453\n",
      "H                 0.8496485340        0.6404518280       -1.5151018938\n",
      "H                 2.6179912682        1.0940032327       -1.3491742317\n",
      "H                 3.9834411235        0.3211441193        0.7742050968\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "calc = gaussian.get_overall_calc(ts=ts)\n",
    "calc.write_input(ts.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C+[O]O_[CH3]+OO_irc_forward_0\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ irc=(calcall) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 2\n",
      "O                 3.1075007166        0.0366083817        1.1380898417\n",
      "O                 2.7719170395       -0.9838382949        0.3778717969\n",
      "C                 1.8945968834        0.2679645289       -1.5076958826\n",
      "H                 2.0535769134       -0.5567744322       -0.3833424702\n",
      "H                 2.1299086782       -0.3061419699       -2.4273764453\n",
      "H                 0.8496485340        0.6404518280       -1.5151018938\n",
      "H                 2.6179912682        1.0940032327       -1.3491742317\n",
      "H                 3.9834411235        0.3211441193        0.7742050968\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "calc = gaussian.get_irc_calc(ts=ts)\n",
    "calc.write_input(ts.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For hindered rotor calculations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CCCC_36by10_0_2\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ Opt=(CalcFC,ModRedun) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 1\n",
      "C                 0.7354773892       -0.5134376003       -0.4435545991\n",
      "C                -0.6152275702       -0.7833727200        0.1347266939\n",
      "C                 1.4708785306        0.6001543075        0.2570064789\n",
      "C                -1.5576774464        0.3717083329       -0.0133286741\n",
      "H                 1.3514541492       -1.4408514250       -0.3998148131\n",
      "H                 0.6384864521       -0.2543841110       -1.5085983108\n",
      "H                -1.0592735869       -1.6822519107       -0.3636475485\n",
      "H                -0.5140400339       -1.0467673405        1.2016221745\n",
      "H                 0.9226907733        1.5490177860        0.1594326502\n",
      "H                 1.5916942864        0.3858269094        1.3352985542\n",
      "H                 2.4876999397        0.7411498210       -0.1864867196\n",
      "H                -1.9843555104        0.4010061669       -1.0420713857\n",
      "H                -1.0400176453        1.3206480008        0.1611748412\n",
      "H                -2.3995677519        0.3031307160        0.6992443636\n",
      "\n",
      "B 1 3\n",
      "B 1 2\n",
      "B 1 6\n",
      "B 1 5\n",
      "B 2 7\n",
      "B 2 8\n",
      "B 2 4\n",
      "B 3 9\n",
      "B 3 10\n",
      "B 3 11\n",
      "B 4 12\n",
      "B 4 13\n",
      "B 4 14\n",
      "D 5 1 3 11 S 36 10.0\n",
      "D 5 1 2 4 F\n",
      "D 8 2 4 14 F\n",
      "\n"
     ]
    }
   ],
   "source": [
    "torsion = conformer.torsions[0]\n",
    "calc = gaussian.get_rotor_calc(conformer=conformer, torsion=torsion)\n",
    "calc.write_input(conformer.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C+[O]O_[CH3]+OO_36by10_0_1\n",
      "\n",
      "%nprocshared=20\n",
      "%mem=5GB\n",
      "#p m062x/cc-pVTZ Opt=(ts,CalcFC,ModRedun) \n",
      "\n",
      "Gaussian input prepared by ASE\n",
      "\n",
      "0 2\n",
      "O                 3.1075007166        0.0366083817        1.1380898417\n",
      "O                 2.7719170395       -0.9838382949        0.3778717969\n",
      "C                 1.8945968834        0.2679645289       -1.5076958826\n",
      "H                 2.0535769134       -0.5567744322       -0.3833424702\n",
      "H                 2.1299086782       -0.3061419699       -2.4273764453\n",
      "H                 0.8496485340        0.6404518280       -1.5151018938\n",
      "H                 2.6179912682        1.0940032327       -1.3491742317\n",
      "H                 3.9834411235        0.3211441193        0.7742050968\n",
      "\n",
      "B 1 8\n",
      "B 1 2\n",
      "B 3 5\n",
      "B 3 6\n",
      "B 3 4\n",
      "B 3 7\n",
      "B 4 2\n",
      "D 8 1 2 4 S 36 10.0\n",
      "D 7 3 4 2 F\n",
      "D 3 4 2 1 F\n",
      "\n"
     ]
    }
   ],
   "source": [
    "torsion = ts.torsions[0]\n",
    "calc = gaussian.get_rotor_calc(conformer=ts, torsion=torsion)\n",
    "calc.write_input(ts.ase_molecule)\n",
    "f = open(calc.label + \".com\", \"r\")\n",
    "print(calc.label)\n",
    "print(\"\")\n",
    "for line in f.readlines():\n",
    "    print(line[:-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "At this point, you now have a way to have input files for quantum chemistry optimizations to be automatically written for you. And you can have all of these run automatically using the AutoTST `Job` class"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (rmg_env)",
   "language": "python",
   "name": "myenv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
